<?php

namespace app\admin\controller;

use app\v1\model\Answer;
use app\v1\model\User;
use think\Controller;
use think\Request;

class Index extends Controller
{
    /**
     * @return \think\response\View
     */
    public function index()
    {
        return view('', ['title' => '首页']);
    }

    /**
     * @return \think\response\View
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function userTestHistory(Request $request)
    {
        $page = $request->get('page') ?? 1;
        $limit = $request->get('limit') ?? 5;
        $arrUsersAnswer = (new Answer())->getUsersLastAnswer($page);
        // 分页数据
        // 用户个数
        $intUserCount = User::where('phone', '>', 0)->count();
        // 多少页
        $intPageCount = ceil($intUserCount / $limit);
        return view('', ['title' => '用户测试记录 ', 'usersAnswer' => $arrUsersAnswer, 'page' => ['count' => $intPageCount, 'limit' => $limit, 'page' => $page]]);
    }

}
